From 5bbc4f270d00f61571ec40414f92fbcb71c3b13f Mon Sep 17 00:00:00 2001 From: parkrrrr Date: Mon, 9 Aug 2004 03:22:22 +0000 Subject: [PATCH] Oops. fabs and labs are SO not the same thing. This fixes a bug where points that were within range of the start of the arc were being ignored when using the arc filter. --- gpsbabel/grtcirc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gpsbabel/grtcirc.c b/gpsbabel/grtcirc.c index 7a0b01c99..d5e5cddbb 100644 --- a/gpsbabel/grtcirc.c +++ b/gpsbabel/grtcirc.c @@ -131,6 +131,8 @@ double linedist(double lat1, double lon1, lp = sqrt(xp*xp+yp*yp+zp*zp); if ( lp ) { + + /* After this, 'p' is normalized */ xp /= lp; yp /= lp; zp /= lp; @@ -140,7 +142,7 @@ double linedist(double lat1, double lon1, crossproduct(xp,yp,zp,x2,y2,z2,&xa2,&ya2,&za2); d2 = dotproduct( xa2, ya2, za2, xa, ya, za ); - + if ( d1 >= 0 && d2 >= 0 ) { /* rather than call gcdist and all its sines and cosines and * worse, we can get the angle directly. It's the arctangent @@ -157,8 +159,8 @@ double linedist(double lat1, double lon1, /* otherwise, get the distance from the closest endpoint */ c1 = dotproduct( x1,y1,z1,xp,yp,zp ); c2 = dotproduct( x2,y2,z2,xp,yp,zp ); - d1 = labs(d1); - d2 = labs(d2); + d1 = fabs(d1); + d2 = fabs(d2); /* This is a hack. d$n$ is proportional to the sine of the angle * between point $n$ and point p. That preserves orderedness up @@ -176,7 +178,7 @@ double linedist(double lat1, double lon1, d2 = 2 - d2; } - if ( labs(d1) < labs(d2)) { + if ( fabs(d1) < fabs(d2)) { return gcdist(lat1,lon1,lat3,lon3); } else { -- 2.30.2